import axios from 'axios'
let url= 'http://localhost:3000'

export const getAll=async (keyword) => {
    let data;
    if (keyword) {
        data = await axios.get(`${url}/book?keyword=${keyword}`)
    }else{
        data = await axios.get(`${url}/book`)
    }
    return data.data;
}

export const getBtId=async (id) => {
    let data =await axios.get(`${url}/book/${id}`)
    return data.data
}

export const delItem =async (id) => {
    let data = await axios.delete(`${url}/book/${id}`)
     return data.data
}

export const addItem = async (obj) => {
    let data =await axios.post(`${url}/book`,obj)
    return data.data
}

export const editItem = async (id,obj) => {
    let data= await axios.put(`${url}/book/${id}`,obj)
    return data.data;
}